﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Step_Parent : RelationBase
    {
        private static Step_Parent _singleton = new Step_Parent();
        public static Step_Parent Instance
        {
            get { return _singleton; }
        }

        private Step_Parent() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's Step_Parent IFF b is not a's Parent and b is the Spouse of a's parent
            return ((!Person.IsNull(a.Mother) && b != a.Mother) &&
                    (!Person.IsNull(a.Father) && b != a.Father) &&
                   (b == a.Mother.Spouse || b == a.Father.Spouse));
            // ignore ex-spouse
            // skip Parent for now (can't use !KnownRelation anyway...)
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Spouse.Instance, Mother.Instance, Father.Instance });
        }
    }
}
